<template>
    <div>
    <ul> 
        <li v-for="item in dataList">{{item}}</li>
        <input type="text" v-model="msg" @change="onInput">
    </ul>
    </div>
</template>

<script>
export default {
  props: {
    dataList: []
  },
  data () {
    return {
      msg: ''
    }
  },
  mounted: function () {
    this.$nextTick(function () {
      this.$on('childMethod', function () {
        console.log('监听成功')
      })
    })
  },
  methods: {
    onInput () {
      if (this.msg.trim()) {
        console.log('子组件调用父组件的方法')
        this.$emit('message', this.msg)
      }
    },
    callMethod () {
      console.log('调用成功')
    }
  }
}
</script>
